import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_pleasure_video/api/api_common.dart';
import 'package:flutter_pleasure_video/api/backstage_api/backstage_api.dart';
import 'package:flutter_pleasure_video/data/model/resources_description_model.dart';
import 'package:flutter_pleasure_video/widget/common/custom_appbar.dart';

class ResourcesDescriptionPage extends StatelessWidget {
  const ResourcesDescriptionPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: CustomAppBar(
        titleString: "资源提示",
      ),
      body: Container(
        child: getDataUi(),
      ),
    );
  }

  Widget getDataUi() {
    return FutureBuilder(
      future: BackstageApi.init().selectAllDescription(),
      builder: (BuildContext context, AsyncSnapshot<List<ResourcesDescriptionModel>?> snapshot) {
      if (snapshot.connectionState == ConnectionState.done) {
        if (snapshot.hasError) {
          return Container(child: Text(snapshot.error.toString()));
        }
        if (snapshot.data == null || snapshot.data!.length < 1) {
          return Container(child: Text("暂无数据"));
        }
        return Container(child: Text(snapshot.data.toString()));
      }
      return Container(child: Text("正在加载"));
    },
    );
  }
}
